﻿//TODO: implement routine, IsoNoiseRemoval

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Imaging;
using System.Drawing;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// Tries to remove iso noise
    /// </summary>
    public class IsoNoiseRemoval : BaseImageFilter
    {
        protected List<Point> aPoint = new List<Point>() { 
                new Point(-1,-1),
                new Point(0,-1),
                new Point(1,-1),
                new Point(1,0),
                new Point(1,1),
                new Point(0,1),
                new Point(-1,1),
                new Point(-1,0)
            };

        /// <summary>
        /// Default constructor
        /// </summary>
        public IsoNoiseRemoval()
        {
        }

        /// <summary>
        /// Executes this filter
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            int nWidth = _bitmap.Width;
            int nHeight = _bitmap.Height;
            
            UnsafeBitmap bitmap = _bitmap;

            int y = 0;
            int x = 0;

            Color[] aColor = new Color[8];
            for (y = 0; y < nHeight; y++)
            {
                for (x = 0; x < nWidth; x++)
                {
                    aColor = Segmentation.GetEnvironmentPixelColorArray(bitmap, x, y, aPoint, aColor);
                }
            }
            return _bitmap;
        }

        /// <summary>
        /// Used to create a deep copy
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new IsoNoiseRemoval();
        }
    }
}
